<template>
  <div>
    <div class="name">{{ son2Name }}</div>
    <div class="storeName">nameY{{ nameY }}</div>
    <div>store里面的优惠券模块的数据 {{ couponMoney }}</div>
    <div>store里面的优惠券模块的数据 {{ qianggouTime }}</div>
    <button @click="modifySon2Name">修改孙子的名字</button>
    <button @click="storeSetTest">设置孙子青青的名字</button>
    <button @click="storeActionSetTest">设置孙子青青的名字</button>
  </div>
</template>

<script>
import EvenBus from "../utils/EvenBus";
export default {
  name: "son2",
  data() {
    return {
      son2Name: "我是孙子杨青青",
    };
  },
  computed: {
    nameY() {
      return this.$store.state.nameY;
    },
    couponMoney() {
      return this.$store.state.coupon.couponMoney;
    },
    qianggouTime() {
      return this.$store.state.qianggou.time;
    },
  },
  methods: {
    modifySon2Name() {
      console.log(1);
      this.$emit("changeSonName", "杨qq");
      console.log(2);
    },
    storeSetTest() {
      this.$store.commit("setNameY", "yqq");
    },
    storeActionSetTest() {
      this.$store.dispatch("setActionSetNameY");
    },
  },
  mounted() {
    EvenBus.$on("xxx", (anhao) => {
      console.log("你给我的暗号是：", anhao);
    });
  },
};
</script>

<style lang="scss" scoped>
</style>
